home *** CD-ROM | disk | FTP | other *** search
/ Gekkan Dennou Club 142 / Gekkan Dennou Club - 2000.3 Vol. 142 (Japan).7z / Gekkan Dennou Club - 2000.3 Vol. 142 (Japan) (Track 1).bin / tools / s_tool / move3.c < prev    next >
Text File  |  1999-06-03  |  10KB  |  513 lines

  1. #include    "JX250.H"
  2. #include    <sys\iocs.h>
  3. #include    <sys\dos.h>
  4. #include    <sys\scsi.h>
  5. #include    <stdio.h>
  6. #include    <stdlib.h>
  7.  
  8. /**********************************************************
  9.         フレームとマウスの関係
  10. [rtn]    -1 ; 違うところ
  11.     0 ; 中
  12.     bit 0 ; 上        bit 1 ; 左
  13.     bit 2 ; 右        bit 3 ; 下
  14. **********************************************************/
  15. int    fream_mousepos(xx,yy)
  16. int    xx,yy;
  17. {
  18. int    r;
  19. r=0;
  20. //--- 中
  21. if ( xx<PreXV1-2 || xx>PreXV2+2 || yy<PreYV1-2 || yy>PreYV2+2 )
  22.     return(-1);
  23. if ( xx<16-2 || xx>232+16+2 || yy<16-2 || yy>496+2 )
  24.     return(-1);
  25. //--- 上チェック
  26. if ( yy<PreYV1+6 ) r|=bit(0);
  27. //--- 左チェック
  28. if ( xx<PreXV1+6 ) r|=bit(1);
  29. //--- 下チェック
  30. if ( yy>PreYV2-6 ){
  31.      r&=nbit(0);
  32.      r|=bit(3);
  33. }
  34. //--- 右チェック
  35. if ( xx>PreXV2-6 ){
  36.      r&=nbit(1);
  37.      r|=bit(2);
  38. }
  39. return( r );
  40. }
  41. /**********************************************************
  42.         ボタン
  43. [in]    x1,y1 = 画面の座標
  44.     x2,y2 = 
  45. [out]     0; 押された
  46.     -1; キャンセルされた
  47. **********************************************************/
  48. int    sxbotton(x1,y1,x2,y2,mm)
  49. int    x1,y1,x2,y2,mm;
  50. {
  51. int    i,j,m,n,x,y,b,rb;
  52. int    xx,yy;
  53. int    gz;
  54. int    ssp;
  55. yy=( i=_ms_curgt_() )&0xFFFF;
  56. xx=i>>16;
  57. if ( xx<x1 || xx>=x2 || yy<y1 || yy>=y2 ){
  58.     // 範囲外
  59.     gz=0;        // 0;押されている
  60.     j=-1;
  61. } else {
  62.     gz=2;        // 2;押されている
  63.     j=2;
  64. }
  65. rb=0;
  66. m=(x2+7)/8;
  67. n=(y2+7)/8;
  68. for(;;){
  69.     _dos_change_pr();
  70.     yy=( i=_ms_curgt_() )&0xFFFF;
  71.     xx=i>>16;
  72.     if ( xx<x1 || xx>=x2 || yy<y1 || yy>=y2 ){
  73.         // 範囲外
  74.         if ( gz!=0 )
  75.             j=0;
  76.     } else {
  77.         // 範囲内
  78.         if ( gz==0 )
  79.             j=2;
  80.     }
  81.     if ( (b=MS_RSW())!=0 )
  82.         break;
  83.     if ( j>=0 ){
  84.         gz=j;
  85.         if ( mm==0 ){
  86.             ssp=_iocs_b_super(0);
  87.             for(y=y1/16;y<n;y++)
  88.                 for(x=x1/16;x<m;x++)
  89.                     if ( gz==0 ){
  90.                         GGSP16_64_S(TADDS(x,y),MAP[x+y*32]);
  91.                     } else{
  92.                         GGICON_ON_S(TADDS(x,y)+32);
  93.                     }
  94.             if ( ssp>0 )
  95.                 _iocs_b_super(ssp);
  96.         } else {
  97.             GGREV(VADDS(0,x1,y1),(x2-x1)+1,(y2-y1)+1);
  98.             rb^=1;
  99.         }
  100.         j=-1;
  101.     }
  102.     b=MS_RSW();
  103.     if ( MS_LSW()==0 || b!=0 )
  104.         break;
  105. }
  106. if ( mm==0 ){
  107.     ssp=_iocs_b_super(0);
  108.     for(y=y1/16;y<n;y++)
  109.         for(x=x1/16;x<m;x++)
  110.             GGSP16_64_S(TADDS(x,y),MAP[x+y*32]);
  111.     if ( ssp>0 )
  112.         _iocs_b_super(ssp);
  113. } else {
  114.     if ( rb!=0 )
  115.         GGREV(VADDS(0,x1,y1),(x2-x1)+1,(y2-y1)+1);
  116. }
  117. if ( gz==0 )
  118.     return(-1);
  119. if ( b!=0 ){
  120.     while( MS_LSW()!=0 || MS_RSW()!=0 );
  121.     return(-1);
  122. }
  123. return(0);
  124. }
  125. /**********************************************************
  126.         数値加減(バー or ボタン)
  127. [in]    mx,my = 画面の座標
  128.     md= -1;バー  0;加減sw  1;減sw 2;増sw
  129.     nw = 現在の値
  130.     high,low = 変化出来る範囲
  131. **********************************************************/
  132. int    kazu_move(mx,my,md,nw,low,high,sub)
  133. int    mx,my,md,nw,high,low;
  134. void    (*sub)();
  135. {
  136. int    i,j,w,ct;
  137. int    xo,yo;
  138. int    onw;
  139. int    mxb,myb;
  140. int    xx,yy,b;
  141. int    ssp;
  142. mxb=mx/16;
  143. myb=my/16;
  144. ct=0;
  145. xo=-1;
  146. yo=-1;
  147. w=-1;
  148. onw=nw;
  149. //(*sub)(nw);
  150. for(;;){
  151.     _dos_change_pr();
  152.     yy=( i=_ms_curgt_() )&0xFFFF;
  153.     xx=i>>16;
  154.     if ( md<0 ){
  155.         // バー
  156.         if ( xo!=xx || yo!=yy ){
  157.             xo=xx;
  158.             yo=yy;
  159.             i=xx-(mxb*16); // (0~62)
  160.             j=(high-low)+1;
  161.             nw=(i*j/62)+low;
  162.             if ( nw<low )
  163.                 nw=low;
  164.             if ( nw>high )
  165.                 nw=high;
  166.             CRTVDISP();
  167.             (*sub)(nw);
  168.         }
  169.     } else {
  170.         // ボタン
  171.         xo=xx;
  172.         yo=yy;
  173.         xx/=16;
  174.         yy/=16;
  175.         ONtim_set(1000);
  176.         if ( mxb==xx && myb==yy ){
  177.             if ( w!=1 ){
  178.                 ssp=_iocs_b_super(0);
  179.                 if ( md==0 ){
  180.                     GGSP16_64_S(TADDS(mxb  ,myb),0x76+1);
  181.                     if ( md==0 ){
  182.                         GGSP16_64_S(TADDS(mxb+1,myb),0x7E);
  183.                     }
  184.                 } else {
  185.                     GGSP16_64_S(TADDS(mxb  ,myb),MAP[mxb  +myb*32]+1);
  186.                     if ( md==0 ){
  187.                         GGSP16_64_S(TADDS(mxb+1,myb),MAP[mxb+1+myb*32]);
  188.                     }
  189.                 }
  190.                 if ( ssp>0 ) _iocs_b_super(ssp);
  191.                 w=1;
  192.             }
  193.             if ( md==0 || md==1 ){
  194.                 // 減
  195.                 if ( low<nw ){
  196.                     nw--;
  197.                     CRTVDISP();
  198.                     (*sub)(nw);
  199.                 }
  200.             } else {
  201.                 // 加
  202.                 if ( high>nw ){
  203.                     nw++;
  204.                     CRTVDISP();
  205.                     (*sub)(nw);
  206.                 }
  207.             }
  208.         } elif ( md==0 && mxb+1==xx && myb==yy ){
  209.             // 加
  210.             if ( w!=2 ){
  211.                 ssp=_iocs_b_super(0);
  212.                 if ( md==0 ){
  213.                     GGSP16_64_S(TADDS(mxb  ,myb),0x76);
  214.                     GGSP16_64_S(TADDS(mxb+1,myb),0x7E+1);
  215.                 } else {
  216.                     GGSP16_64_S(TADDS(mxb  ,myb),MAP[mxb  +myb*32]);
  217.                     GGSP16_64_S(TADDS(mxb+1,myb),MAP[mxb+1+myb*32]+1);
  218.                 }
  219.                 if ( ssp>0 ) _iocs_b_super(ssp);
  220.                 w=2;
  221.             }
  222.             if ( high>nw ){
  223.                 nw++;
  224.                 CRTVDISP();
  225.                 (*sub)(nw);
  226.             }
  227.         } else {
  228.             // 位置がずれた
  229.             if ( w!=3 ){
  230.                 ssp=_iocs_b_super(0);
  231.                 if ( md==0 ){
  232.                     GGSP16_64_S(TADDS(mxb  ,myb),0x76);
  233.                     if ( md==0 ){
  234.                         GGSP16_64_S(TADDS(mxb+1,myb),0x7E);
  235.                     }
  236.                 } else {
  237.                     GGSP16_64_S(TADDS(mxb  ,myb),MAP[mxb  +myb*32]);
  238.                     if ( md==0 ){
  239.                         GGSP16_64_S(TADDS(mxb+1,myb),MAP[mxb+1+myb*32]);
  240.                     }
  241.                 }
  242.                 if ( ssp>0 ) _iocs_b_super(ssp);
  243.                 w=3;
  244.             }
  245.         }
  246.         if ( ct==0 )
  247.             j=25;
  248.         elif ( ct<8 )
  249.             j=15;
  250.         elif ( ct<16 )
  251.             j=7;
  252.         else    j=1;
  253.         ct++;
  254.         while( ONtim_count()<j ){
  255.             yy=( i=_ms_curgt_() )&0xFFFF;
  256.             //xx=i>>16;
  257.         }
  258.     }
  259.     b=MS_RSW();
  260.     if ( b!=0 )
  261.         break;
  262.     if ( MS_LSW()==0 )
  263.         break;
  264. }
  265. if ( md<0 ){
  266.     ;
  267. } else {
  268.     ssp=_iocs_b_super(0);
  269.     if ( md==0 ){
  270.         GGSP16_64_S(TADDS(mxb  ,myb),0x76);
  271.         if ( md==0 )
  272.             GGSP16_64_S(TADDS(mxb+1,myb),0x7E);
  273.     } else {
  274.         GGSP16_64_S(TADDS(mxb  ,myb),MAP[mxb  +myb*32]);
  275.         if ( md==0 )
  276.             GGSP16_64_S(TADDS(mxb+1,myb),MAP[mxb+1+myb*32]);
  277.     }
  278.     if ( ssp>0 ) _iocs_b_super(ssp);
  279. }
  280. if ( b!=0 ){
  281.     //右クリック キャンセル
  282.     CRTVDISP();
  283.     (*sub)(onw);
  284.     while( MS_LSW()!=0 || MS_RSW()!=0 );
  285.     return(1);
  286. }
  287. return(0);
  288. }
  289. /**********************************************************
  290.         X のスクロールバー
  291.     fl= 全体の大きさ
  292.     bl= 物体の大きさ
  293.     ml= 物体の位置
  294. **********************************************************/
  295. void    ScroolBarX(fl,bl,ml)
  296. int    fl,bl,ml;
  297. {
  298. int    i,j;
  299. struct _fillptr PP;
  300. PP.y1=31*16+6;
  301. PP.y2=31*16+10;
  302. //-
  303. if ( fl<=0 ){
  304.     // バー無し
  305.     PP.x1=32;
  306.     PP.x2=15*16-1;
  307.     PP.color=PalTable[0xD];
  308.     _iocs_fill(&PP);        // 溝
  309.     return;
  310. }
  311. i=bl *(15*16-32)/fl;
  312. j=ml *(15*16-32)/fl;
  313. _iocs_window(32,0,15*16-1,511);
  314. PP.x1=32;
  315. PP.x2=32+j;
  316. PP.color=PalTable[0xD];
  317. _iocs_fill(&PP);        // 溝
  318. PP.x1=32+j;
  319. PP.x2=32+j+i;
  320. PP.color=PalTable[0xF];
  321. _iocs_fill(&PP);        // 溝
  322. PP.x1=32+j+i;
  323. PP.x2=15*16-1;
  324. PP.color=PalTable[0xD];
  325. _iocs_fill(&PP);        // 溝
  326. _iocs_window(0,0,511,511);
  327. }
  328. /**********************************************************
  329.         Y のスクロールバー
  330.     fl= 全体の大きさ
  331.     bl= 物体の大きさ
  332.     ml= 物体の位置
  333. **********************************************************/
  334. void    ScroolBarY(fl,bl,ml)
  335. int    fl,bl,ml;
  336. {
  337. int    i,j;
  338. struct _fillptr PP;
  339. PP.x1=6;
  340. PP.x2=9;
  341. //-
  342. if ( fl<=0 ){
  343.     // バー無し
  344.     PP.y1=32;
  345.     PP.y2=30*16-1;
  346.     PP.color=PalTable[0xD];
  347.     _iocs_fill(&PP);        // 溝
  348.     return;
  349. }
  350. i=bl *(30*16-32)/fl;
  351. j=ml *(30*16-32)/fl;
  352. _iocs_window(0,32,511,30*16-1);
  353. PP.y1=32;
  354. PP.y2=32+j;
  355. PP.color=PalTable[0xD];
  356. _iocs_fill(&PP);        // 溝
  357. PP.y1=32+j;
  358. PP.y2=32+j+i;
  359. PP.color=PalTable[0xF];
  360. _iocs_fill(&PP);        // 溝
  361. PP.y1=32+j+i;
  362. PP.y2=30*16-1;
  363. PP.color=PalTable[0xD];
  364. _iocs_fill(&PP);        // 溝
  365. _iocs_window(0,0,511,511);
  366. }
  367. /**********************************************************
  368.                    マウスボタン判定
  369. **********************************************************/
  370. int    MS_LSW()
  371. {
  372. return( (_iocs_ms_getdt()&bit(8)) );
  373. }
  374. /*+++*/
  375. int    MS_LSW2(){
  376. return( ((_iocs_ms_getdt()&bit(8))!=0)?-1:0 );
  377. }
  378. /*+++*/
  379. int    MS_RSW(){
  380. return( ((_iocs_ms_getdt()&bit(0))!=0)?-1:0 );
  381. }
  382. /**********************************************************
  383.     G
  384. **********************************************************/
  385. void    GraphicV(mo)
  386. int    mo;
  387. {
  388. int    o;
  389. o=B_WPEEK((void*)0xe82600);
  390. if ( mo==0 ){
  391.     // 見えなくする
  392.     B_WPOKE((void*)0xe82600,o&0xfff0);
  393. } else {
  394.     // 見える
  395.     B_WPOKE((void*)0xe82600,o|0x000f);
  396. }
  397. }
  398. /**********************************************************
  399.     TEXT VRAM クリア
  400. [in] m= 0 ; 見えるところだけ
  401.     1 ; 全部
  402. **********************************************************/
  403. void    TXCLS(m)
  404. int    m;
  405. {
  406. int    i,x,y;
  407. int    *a1,*a2,*a3,*a4;
  408. int    ssp;
  409. ssp=_iocs_b_super(0);
  410. if ( m==0 ){
  411.     for(y=0;y<512;y++){
  412.         a1=(void*)(0xE00000+y*128);
  413.         a2=(void*)(0xE20000+y*128);
  414.         a3=(void*)(0xE40000+y*128);
  415.         a4=(void*)(0xE60000+y*128);
  416.         for(x=0;x<128/4;x++){
  417.             *a1++=0;
  418.             *a2++=0;
  419.             *a3++=0;
  420.             *a4++=0;
  421.         }
  422.     }
  423. } elif ( m==1 ){
  424.     a1=(void*)0xE00000;
  425.     for(i=0;i<0x80000/4;i++)
  426.         *a1++=0;
  427. }
  428. if ( ssp>=0 )
  429.     _iocs_b_super(ssp);
  430. }
  431. /******************************************
  432.     画面比設定
  433. *******************************************/
  434. void    AspScreen()
  435. {
  436. int    ssp;
  437. _iocs_crtmod(0x100+12);
  438. if ( AspMode!=0 ){    // 「画像」の 0;(2:3) 1;(1:1)
  439.     ssp=_iocs_b_super(0);
  440.      *(char *)0xe80029=(char)0x16;        //CRTC-R20
  441.      *(char *)0xe80001=(char)0x89;        //CRTC-R00
  442.      *(char *)0xe80003=(char)0x0e;        //CRTC-R01
  443.      *(char *)0xe80005=(char)0x1c+0x10;    //CRTC-R02
  444.      *(char *)0xe80007=(char)0x5c+0x10;    //CRTC-R03
  445.     if ( ssp>0 )
  446.         _iocs_b_super(ssp);
  447. }
  448. return;
  449. }
  450. /*+*****************************************
  451.     マウス座標とか
  452. ********************************************/
  453. UNint    _ms_curgt_()
  454. {
  455. static    int    tm=0;
  456. static    short    cc=-1;
  457. static    UNshort    ss[]={    RGB(31,31,31),
  458.             RGB(29,29,29),
  459.             RGB(27,27,27),
  460.             RGB(25,25,25),
  461.             RGB(23,23,23),
  462.             RGB(25,25,25),
  463.             RGB(27,27,27),
  464.             RGB(29,29,29)
  465. };
  466. if ( cc<0 ){
  467.     cc=0;
  468.     tm=_iocs_ontime();
  469. }
  470. if ( (_iocs_ontime()-tm)>8 ){
  471.     tm=_iocs_ontime();
  472.     CRTVDISP();
  473.     _iocs_tpalet(3,ss[cc]);
  474. //    _iocs_tpalet(8,ss[cc]);
  475.     cc=(cc+1)&7;
  476. }
  477. return( _iocs_ms_curgt() );
  478. }
  479. /*+*****************************************
  480.     ロゴ設定
  481. ********************************************/
  482. void    JxLogoChain()
  483. {
  484. int    i,j,m,n,x,y;
  485. UNchar    *ss;
  486. UNchar    *a,*b;
  487. UNchar    *G,*T;
  488. extern    int    GGSP16_64_BUFF;
  489. extern    int    TTL_DATA;
  490. G=GGSP16_64_BUFF;
  491. T=TTL_DATA;
  492. if ( jxscanner==_JX250_ ){
  493.     ss=&T[0];
  494. } elif ( jxscanner==_JX350_ ){
  495.     ss=&T[128*4];
  496. } elif ( jxscanner==_JX330_ ){
  497.     ss=&T[128*8*4];
  498. } elif ( jxscanner==_JX325_ ){
  499.     ss=&T[128*4+128*8*4];
  500. } elif ( jxscanner==_JX270_ ){
  501.     ss=&T[128*16*4];
  502. } else {
  503.     return;
  504. }
  505. for(y=0;y<4;y++){
  506.     a=&G[(0xd3+8*y)*128];
  507.     b=&ss[(8*y)*128];
  508.     for(x=0;x<128*4;x++)
  509.         *a++=*b++;
  510. }
  511. return;
  512. }
  513.